
#include "AutoObject.h"

/* Constructor
 */
AutoObject::AutoObject() :
	m_ObjectType(AUTONOMOUS),
	m_Tag(false),
	m_Pos(Ogre::Vector3::ZERO),
	m_Scale(Ogre::Vector3(1)),
	m_BoundingRadius(1.0),
	m_Velocity(Ogre::Vector3::ZERO),
	m_Heading(Ogre::Vector3::ZERO),
	m_Perp(Ogre::Vector3::ZERO),
	m_Acceleration(Ogre::Vector3::ZERO),
	m_AppliedForce(Ogre::Vector3::ZERO),
	m_Mass(1.0),
	m_MaxSpeed(2000.0),
	m_MaxForce(1e16),
	m_MaxTurnRate(1000.0),
	m_Steering(NULL),
	m_HeadingSmoother(Ogre::Vector3::ZERO),
	m_SmoothedHeading(Ogre::Vector3::ZERO),
	m_SmoothingOn(false),
	m_TimeElapsed(0.0)
{
	m_ID = GameServices::ObjectManager()->GetAutonomousObjectCount();
}


/* Deconstructor
 */
AutoObject::~AutoObject()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::~AutoObject() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	delete m_Steering;

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::~AutoObject() ");
	}
}


/* Initialize
 */
void AutoObject::Initialize()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1) //debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::Initialize() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	m_Steering = new SteeringBehaviors(this);

	if(GameServices::GameEngine()->GetLoggingLevel() > 1) //debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::Initialize() ");
	}
}


/* UpdateStarted(const Ogre::FrameEvent& gameTime)
 * Update the motion of the object
 */
void AutoObject::UpdateStarted(const Ogre::FrameEvent& gameTime)
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4 && 
		GameServices::OgreManager()->GetRoot()->getNextFrameNumber() % 120 == 0)	//debug
		//Output only every 120 frames
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::UpdateStarted(const Ogre::FrameEvent& gameTime) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::StateManager()->CurrentState()->IsRunning())
	{
		//Store the time elapsed since the last frame
		m_TimeElapsed = gameTime.timeSinceLastFrame;

		//Calculate the steering force based on the active behaviors
		Ogre::Vector3 SteeringForce = m_Steering->Calculate();

		//acceleration = force / mass
		m_Acceleration = SteeringForce / m_Mass;

		if(m_Acceleration == Ogre::Vector3::ZERO)
		//If there no acceleration slow the object down naturally
		{
			//Store the Velocity for referance
			Ogre::Vector3 VelocityBeforeSlowDown = m_Velocity;

			//If there is no acceleration in the x direction
			if(m_Velocity != Ogre::Vector3::ZERO)
			{
				//Slow down
				m_Velocity = m_Velocity + (-(m_Velocity.normalisedCopy()) * (m_Mass * GRAVITY * .3));
											//unit vector opposite the direction of motion * magnitued of the frictional force

				if(m_Velocity.x < 0 && VelocityBeforeSlowDown.x > 0)
				{
					m_Velocity.x = 0;
				}
				else if(m_Velocity.x > 0 && VelocityBeforeSlowDown.x < 0)
				{
					m_Velocity.x = 0;
				}

				if(m_Velocity.y < 0 && VelocityBeforeSlowDown.y > 0)
				{
					m_Velocity.y = 0;
				}
				else if(m_Velocity.y > 0 && VelocityBeforeSlowDown.y < 0)
				{
					m_Velocity.y = 0;
				}
			}
		}
		else
		//else calculate the new velocity based on the current 
		//acceleration and the time since the last frame
		{
			//New velocity = Vi + At
			m_Velocity = m_Velocity + m_Acceleration * gameTime.timeSinceLastFrame;
		}

		//Ensure the velocity stays within bounds (x and y checks for now)
		if(m_Velocity != Ogre::Vector3::ZERO)
		{
			if(m_Velocity.x  < 1e-8 && m_Velocity.x > 0)
				m_Velocity.x = 0;
			else if(m_Velocity.x  > -1e-8 && m_Velocity.x < 0)
				m_Velocity.x = 0;

			if(m_Velocity.y  < 1e-8 && m_Velocity.y > 0)
				m_Velocity.y = 0;
			else if(m_Velocity.y  > -1e-8 && m_Velocity.y < 0)
				m_Velocity.y = 0;

			if(m_Velocity.x > m_MaxSpeed)
				m_Velocity.x = m_MaxSpeed;
			else if(m_Velocity.x < -m_MaxSpeed)
				m_Velocity.x = -m_MaxSpeed;

			if(m_Velocity.y > m_MaxSpeed)
				m_Velocity.y = m_MaxSpeed;
			else if(m_Velocity.y < -m_MaxSpeed)
				m_Velocity.y = -m_MaxSpeed;

			if(m_Velocity.z != 0)
			{
				m_Velocity.z = 0;
			}
		}

		//Update the heading and the perpendicular
		if(m_Velocity.length() > 1e-8)
		{
			m_Heading = m_Velocity.normalisedCopy();
			GetPerp();
		}
		else
		{
			m_Heading = Ogre::Vector3::ZERO;
			m_Perp = Ogre::Vector3::ZERO;
		}

		m_Pos = m_Pos + m_Velocity * gameTime.timeSinceLastFrame;


		//if(Steering()->isSpacePartitioningOn())
		//{
		//	
		//}

		//if(isSmoothingOn())
		//{
		//	m_SmoothedHeading = m_HeadingSmoother->Update(Heading());
		//}
	}
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4 /*&& 
		GameServices::OgreManager()->GetRoot()->getNextFrameNumber() % 120 == 0*/)	//debug
		//Output only every 120 frames
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Autonomous ID " + Ogre::StringConverter::toString(m_ID));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage(" *****Position is (" + Ogre::StringConverter::toString(m_Pos.x) + "," + 
			Ogre::StringConverter::toString(m_Pos.y) + "," + Ogre::StringConverter::toString(m_Pos.z) + ")***** ");
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage(" *****Heading is (" + Ogre::StringConverter::toString(m_Heading.x) + "," + 
			Ogre::StringConverter::toString(m_Heading.y) + "," + Ogre::StringConverter::toString(m_Heading.z) + ")***** ");
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage(" *****Velocity is (" + Ogre::StringConverter::toString(m_Velocity.x) + "," + 
			Ogre::StringConverter::toString(m_Velocity.y) + "," + Ogre::StringConverter::toString(m_Velocity.z) + ")***** ");
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage(" *****Acceleration is (" + Ogre::StringConverter::toString(m_Acceleration.x) + "," + 
			Ogre::StringConverter::toString(m_Acceleration.y) + "," + Ogre::StringConverter::toString(m_Acceleration.z) + ")***** ");
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage(" *****Force is (" + Ogre::StringConverter::toString(m_AppliedForce.x) + "," + 
			Ogre::StringConverter::toString(m_AppliedForce.y) + "," + Ogre::StringConverter::toString(m_AppliedForce.z) + ")***** ");
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4 && 
		GameServices::OgreManager()->GetRoot()->getNextFrameNumber() % 120 == 0)	//debug
		//Output only every 120 frames
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::UpdateStarted(const Ogre::FrameEvent& gameTime) ");
	}
}


/* UpdateEnded(const Ogre::FrameEvent& gameTime)
 */
void AutoObject::UpdateEnded(const Ogre::FrameEvent& gameTime)
{
}


/* Cleanup()
 * TODO
 */
void AutoObject::Cleanup()
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::Cleanup() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::Cleanup() ");
	}
}


/* Draw()
 * Not used
 */
void AutoObject::Draw()
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::Draw() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::Draw() ");
	}
}


/* HandleMessage(int message)
 * Not used
 */
bool AutoObject::HandleMessage(int message)
{
	return true;
}


/* GetPosition()
 * Returns Vector3 m_Pos
 */
Ogre::Vector3 AutoObject::GetPosition()
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4 && 
		GameServices::OgreManager()->GetRoot()->getNextFrameNumber() % 120 == 0)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetPosition() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5 && 
		GameServices::OgreManager()->GetRoot()->getNextFrameNumber() % 120 == 0)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Current Position " + 
			Ogre::StringConverter::toString(m_Pos));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4 && 
		GameServices::OgreManager()->GetRoot()->getNextFrameNumber() % 120 == 0)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetPosition() ");
	}
	return m_Pos;
}


/* SetPostion(Ogre::Vector3 pos)
 * Sets Vector3 m_Pos
 */
void AutoObject::SetPostion(Ogre::Vector3 pos)
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetPostion(Ogre::Vector3 pos) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("New Position " + 
			Ogre::StringConverter::toString(pos));
	}

	m_Pos = pos;

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetPostion(Ogre::Vector3 pos) ");
	}
}


/* GetBRadius()
 * Returns double m_BoundingRadius
 */
double AutoObject::GetBRadius()
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetBRadius() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Current Bounding Radius " + 
			Ogre::StringConverter::toString((int)m_BoundingRadius));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetBRadius() ");
	}
	return m_BoundingRadius;
}


/* SetBRadius(double r)
 * Sets double m_BoundingRadius
 */
void AutoObject::SetBRadius(double r)
{ 
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetBRadius(double r) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("New Bounding Radius " + 
			Ogre::StringConverter::toString((int)r));
	}

	m_BoundingRadius = r;

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetBRadius(double r) ");
	}
}


/* GetID()
 * Returns integer m_ID
 */
int AutoObject::GetID()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetID() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Autonomous ID #" + 
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetID() ");
	}
	return m_ID;
}


/* SetID(int id)
 * Sets integer m_ID
 */
void AutoObject::SetID(int id)
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetID(int id) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("New Autonomous ID is " + 
			Ogre::StringConverter::toString(id));
	}

	m_ID = id;

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetID(int id) ");
	}
}


/* IsTagged()
 * Returns a bool with the status of m_Tag
 */
bool AutoObject::IsTagged()
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::IsTagged() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Is AutoObject Taged? " + 
			Ogre::StringConverter::toString(m_Tag, true));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::IsTagged() ");
	}
	return m_Tag;
}


/* Tag()
 * Sets boolean m_Tag to true
 */
void AutoObject::Tag()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::Tag() | ID #" +
			Ogre::StringConverter::toString(m_ID));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("<= <= <= <= <= <= Tagged AutoObject " + Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::Tag() ");
	}
	m_Tag = true;
}


/* UnTag()
 * Sets boolean m_Tag to false
 */
void AutoObject::UnTag()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::UnTag() ");
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("=> => => => => => => Untagged AutoObject " + Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::UnTag() ");
	}
	m_Tag = false;
}


/* GetScale()
 * Returns the integer m_Scale
 */
Ogre::Vector3 AutoObject::GetScale()
{ 
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetScale() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Current Scale is " + 
			Ogre::StringConverter::toString(m_Scale));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetScale() ");
	}
	return m_Scale;
}


/* SetScale(Ogre::Vector3 nScale)
 * Sets the Vector3 m_Scale
 */
void AutoObject::SetScale(Ogre::Vector3 nScale)
{ 
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetScale(Ogre::Vector3 nScale) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("New Scale is " + 
			Ogre::StringConverter::toString(nScale));
	}

	m_Scale = nScale;

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetScale(Ogre::Vector3 nScale) ");
	}
}


/* SetScale(double nScale)
 * Sets the individual components of the Vector3 m_Scale
 */
void AutoObject::SetScale(double nScale)
{ 
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetScale(double nScale) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetScale(double nScale) ");
	}
	m_Scale = Ogre::Vector3(nScale);
}


/* GetObjectType()
 * Returns the enum ObjectType m_ObjectType
 * The enumeration is declared in IObject.h
 */
ObjectType AutoObject::GetObjectType()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetObjectType() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage(Ogre::StringConverter::toString(m_ObjectType));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetObjectType() ");
	}
	return m_ObjectType;
}


/* SetObjectType(ObjectType nType)
 * Sets the enum ObjectType m_ObjectType
 * The enumeration is declared in IObject.h
 */
void AutoObject::SetObjectType(ObjectType nType)
{ 
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetObjectType(ObjectType nType) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage(Ogre::StringConverter::toString(nType));
	}

	m_ObjectType = nType;

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetObjectType(ObjectType nType) ");
	}
}


/* Write(std::ostream& os)
 * Not used
 */
void AutoObject::Write(std::ostream& os)
{ 

}


/* Read(std::istream& is)
 * Not used
 */
void AutoObject::Read(std::istream& is)
{ 

}


/* GetVelocity()
 * Get the Vector3 m_velocity
 */
Ogre::Vector3 AutoObject::GetVelocity()
{ 
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4 && 
		GameServices::OgreManager()->GetRoot()->getNextFrameNumber() % 120 == 0)	//debug
		//Output only every 120 frames
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetVelocity() | ID #" +
			Ogre::StringConverter::toString(m_ID));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("GET VELOCITY >>>>>>>>>>> " +
			Ogre::StringConverter::toString(m_Velocity));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetVelocity() ");
	}

	return m_Velocity;
}


/* SetVelocity(Ogre::Vector3 nVelocity)
 * Sets the Vector3 m_Velocity
 */
void AutoObject::SetVelocity(Ogre::Vector3 nVelocity)
{ 
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetVelocity(Ogre::Vector3 nVelocity) | ID #" +
			Ogre::StringConverter::toString(m_ID));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("SET VELOCITY >>>>>>>>>>> " +
			Ogre::StringConverter::toString(nVelocity));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetVelocity(Ogre::Vector3 nVelocity) ");
	}

	m_Velocity = nVelocity;
}


/* GetMass()
 * Returns the double m_Mass
 */
double AutoObject::GetMass()
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetMass() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Mass is " + Ogre::StringConverter::toString((int)m_Mass));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetMass() ");
	}
	return m_Mass;
}


/* SetMass(double nMass)
 * Sets the double m_Mass
 */
void AutoObject::SetMass(double nMass)
{ 
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetMass(double nMass) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug	
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("New Mass is " + Ogre::StringConverter::toString((int)nMass));
	}

	m_Mass = nMass;
	
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetMass(double nMass)");
	}
}


/* GetPerp()
 * Returns the Vector3 m_Perp
 * m_Perp is perpendicular to the heading
 */
Ogre::Vector3 AutoObject::GetPerp()
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetPerp() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	//Define a rotation matrix to rotate the heading 90 degrees clockwise												
	Ogre::Matrix3 rotMat(	0,	1,	0, 
							-1,	0,	0, 
							0,	0,	0	);	

	//Using a 3d matrix like a 2d matrix and keeping the rotations in one plane

	m_Perp = rotMat * m_Heading;

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage(" ******* Perpendicular " + 
			Ogre::StringConverter::toString(m_Perp));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetPerp() ");
	}

	return m_Perp;
	
}


/* GetMaxSpeed()
 * Returns the double m_MaxSpeed
 */
double AutoObject::GetMaxSpeed()
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetMaxSpeed() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetMaxSpeed() ");
	}
	return m_MaxSpeed;
}


/* SetMaxSpeed(double nSpeed)
 * Sets the double m_MaxSpeed
 */
void AutoObject::SetMaxSpeed(double nSpeed)
{ 
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetMaxSpeed(double nSpeed) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetMaxSpeed(double nSpeed) ");
	}
	m_MaxSpeed = nSpeed;
}


/* GetMaxForce()
 * Returns the double m_MaxForce
 */
double AutoObject::GetMaxForce()
{ 
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetMaxForce() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetMaxForce() ");
	}
	return m_MaxForce;
}


/* SetMaxForce(double nForce)
 * Sets the double m_MaxForce
 */
void AutoObject::SetMaxForce(double nForce)
{ 
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetMaxForce(double nForce) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetMaxForce(double nForce) ");
	}
	m_MaxForce = nForce;
}

/* SetAppliedForce(Ogre::Vector3 nForce)
 * Sets the Vector3 m_AppliedForce
 */
void AutoObject::SetAppliedForce(Ogre::Vector3 nForce)
{
	if(GameServices::GameEngine()->GetLoggingLevel()>= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetAppliedForce(Ogre::Vector3 nForce) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("New Applied Force " + 
			Ogre::StringConverter::toString(nForce));
	}

	m_AppliedForce = nForce;

	if(GameServices::GameEngine()->GetLoggingLevel()>= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetAppliedForce() ");
	}
}

/* GetAppliedForce()
 * Gets the Vector3 m_AppliedForce
 */
Ogre::Vector3 AutoObject::GetAppliedForce()
{
	if(GameServices::GameEngine()->GetLoggingLevel()>= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetAppliedForce() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Applied Force " + 
			Ogre::StringConverter::toString(m_AppliedForce));
	}

	if(GameServices::GameEngine()->GetLoggingLevel()>= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetAppliedForce() ");
	}
	return m_AppliedForce;
}

/* IsSpeedMaxedOut()
 * Returns true if the AutoObject is traveling
 * at or over its m_MaxSpeed, else returns false
 */
bool AutoObject::IsSpeedMaxedOut()
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::IsSpeedMaxedOut() | ID #" +
			Ogre::StringConverter::toString(m_ID));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage(Ogre::StringConverter::toString((Speed() >= m_MaxSpeed), true));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::IsSpeedMaxedOut() ");
	}

	if(Speed() >= m_MaxSpeed)
		return true;
	else
		return false;
}


/* Speed()
 * Returns the scalar speed
 */
double AutoObject::Speed()
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::Speed() | ID #" +
			Ogre::StringConverter::toString(m_ID));

		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("SPEED --> " +
			Ogre::StringConverter::toString(Ogre::Math::Sqrt(Ogre::Math::Sqr(m_Velocity.x) + Ogre::Math::Sqr(m_Velocity.y) + Ogre::Math::Sqr(m_Velocity.z))));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::Speed() ");
	}

	return Ogre::Math::Sqrt(						//|v| = sqrt(x^2+y^2+z^2)
		(Ogre::Math::Sqr(m_Velocity.x) + Ogre::Math::Sqr(m_Velocity.y) + Ogre::Math::Sqr(m_Velocity.z)));
}


/* SpeedSq()
 * Returns the scalar speed squared
 */
double AutoObject::SpeedSq()
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SpeedSq() | ID #" +
			Ogre::StringConverter::toString(m_ID));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("SPEED SQUARED --> " +
			Ogre::StringConverter::toString((Ogre::Math::Sqr(m_Velocity.x) + Ogre::Math::Sqr(m_Velocity.y) + Ogre::Math::Sqr(m_Velocity.z))));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SpeedSq() ");
	}
							
						//|v^2| = x^2+y^2+z^2
	return (Ogre::Math::Sqr(m_Velocity.x) + Ogre::Math::Sqr(m_Velocity.y) + Ogre::Math::Sqr(m_Velocity.z));
}


/* GetHeading()
 * Returns Vector3 m_Heading
 * The direction the AutoObject is moving
 */
Ogre::Vector3 AutoObject::GetHeading()
{
	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetHeading() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Heading " + 
			Ogre::StringConverter::toString(m_Heading));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)    //debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetHeading() ");
	}
	return m_Heading;
}


/* SetHeading(Ogre::Vector3 nHeading)
 * Sets Vector3 m_Heading
 */
void AutoObject::SetHeading(Ogre::Vector3 nHeading)
{ 
	m_Heading = nHeading;

	//Debug
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetHeading(Ogre::Vector3 nHeading) | ID #" +
			Ogre::StringConverter::toString(m_ID));
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("The new heading is (" + Ogre::StringConverter::toString(m_Heading.x) + "," + 
			Ogre::StringConverter::toString(m_Heading.y) + "," + Ogre::StringConverter::toString(m_Heading.z) + ")");	
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetHeading(Ogre::Vector3 nHeading) ");
	}
}

/* SetHeading(int xHeading, int yHeading, int zHeading)
 * Sets Vector3 m_Heading
 */
void AutoObject::SetHeading(int xHeading, int yHeading, int zHeading)
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetHeading(int xHeading, int yHeading, int zHeading) ");
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("The new heading is (" + Ogre::StringConverter::toString(xHeading) + "," + 
			Ogre::StringConverter::toString(yHeading) + "," + Ogre::StringConverter::toString(zHeading) + ")");
	}

	m_Heading.x = (Ogre::Real)xHeading;
	m_Heading.y = (Ogre::Real)yHeading;
	m_Heading.z = (Ogre::Real)zHeading;

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetHeading(int xHeading, int yHeading, int zHeading) ");
	}
}

/* RotateHeadingToFacePosition(Ogre::Vector3 target)
 * TODO
 */
bool AutoObject::RotateHeadingToFacePosition(Ogre::Vector3 target)
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::RotateHeadingToFacePosition(Ogre::Vector3 target) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::RotateHeadingToFacePosition(Ogre::Vector3 target) ");
	}
	return true;
}


/* GetMaxTurnRate()
 * Returns the double m_MaxTurnRate
 */
double AutoObject::GetMaxTurnRate()
{
	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetMaxTurnRate() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() >= 4)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetMaxTurnRate() ");
	}
	return m_MaxTurnRate;
}


/* SetMaxTurnRate(double nRate)
 * Sets the double m_MaxTurnRate
 */
void AutoObject::SetMaxTurnRate(double nRate)
{ 
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetMaxTurnRate(double nRate) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetMaxTurnRate(double nRate) ");
	}
	m_MaxTurnRate = nRate;
}

/* AutoObject::GetCurrentAccel()
 * Get the Vector3 m_Acceleration
 */
Ogre::Vector3 AutoObject::GetCurrentAccel()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetCurrentAccel() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("Current Acceleration " + 
			Ogre::StringConverter::toString(m_Acceleration));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetCurrentAccel() ");
	}
	return m_Acceleration;
}

/* SetCurrentAccel(Ogre::Vector3 nAccel)
 * Set the Vector3 m_Acceleration
 */
void AutoObject::SetCurrentAccel(Ogre::Vector3 nAccel)
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetCurrentAccel(Ogre::Vector3 nAccel) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("New Acceleration " + 
			Ogre::StringConverter::toString(nAccel));
	}

	m_Acceleration = nAccel;

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetCurrentAccel(Ogre::Vector3 nAccel) ");
	}
}

/* SetCurrentAccel(double xAccel, double yAccel, double zAccel)
 * Set the Vector3 m_Acceleration
 */
void AutoObject::SetCurrentAccel(double xAccel, double yAccel, double zAccel)
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetCurrentAccel(double xAccel, double yAccel, double zAccel) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	m_Acceleration.x = xAccel;
	m_Acceleration.y = yAccel;
	m_Acceleration.z = zAccel;

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("New Acceleration" + 
			Ogre::StringConverter::toString(m_Acceleration));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetCurrentAccel(double xAccel, double yAccel, double zAccel) ");
	}
}

/* Steering()
 * Access the private member m_Steering
 */
SteeringBehaviors* AutoObject::Steering()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::Steering() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::Steering() ");
	}
	return m_Steering;
}

/* SmoothedHeading()
 * TODO
 */
Ogre::Vector3 AutoObject::SmoothedHeading()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SmoothedHeading() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SmoothedHeading() ");
	}
	return Ogre::Vector3::ZERO;
}

/* isSmoothingOn()
 * Return the state of m_SmoothingOn
 */
bool AutoObject::isSmoothingOn()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::isSmoothingOn() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::isSmoothingOn() ");
	}
	return m_SmoothingOn;
}

/* SmoothingOn()
 * Set m_SmoothingOn = true
 */
void AutoObject::SmoothingOn()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SmoothingOn() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	m_SmoothingOn = true;

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SmoothingOn() ");
	}
}

/* SmoothingOff()
 * Set m_SmoothingOn = false;
 */
void AutoObject::SmoothingOff()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SmoothingOff() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	m_SmoothingOn = false;

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SmoothingOff() ");
	}
}

/* ToggleSmoothing()
 * Set m_SmoothingOn = !m_SmoothingOn
 */
void AutoObject::ToggleSmoothing()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::ToggleSmoothing() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	m_SmoothingOn = !m_SmoothingOn;

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::ToggleSmoothing() ");
	}
}

/* TimeElapsed()
 * Return m_TimeElapsed
 */
double AutoObject::TimeElapsed()
{
	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::TimeElapsed() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() > 1)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::TimeElapsed() ");
	}
	return m_TimeElapsed;
}

/* SetName(Ogre::Sting nName)
 * Set m_Name
 */
void AutoObject::SetName(Ogre::String nName)
{
	if(GameServices::GameEngine()->GetLoggingLevel() == 5)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::SetName(Ogre::String nName) | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	m_Name = nName;

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::SetName(Ogre::String nName) ");
	}
}

/* GetName()
 * Return m_Name
 */
Ogre::String AutoObject::GetName()
{
	if(GameServices::GameEngine()->GetLoggingLevel() == 5)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== ENTER AutoObject::GetName() | ID #" +
			Ogre::StringConverter::toString(m_ID));
	}

	if(GameServices::GameEngine()->GetLoggingLevel() == 5)	//debug
	{
		Ogre::LogManager::getSingleton().getLog("Dlog.txt")->logMessage("========== EXIT AutoObject::GetName() ");
	}
	return m_Name;
}